﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Quản_Lý_Thư_Viện
{
    public partial class frmThongTinThanhVien : Form
    {
        public frmThongTinThanhVien()
        {
            InitializeComponent();
        }

        DocgiaControl dgcontrol = new DocgiaControl();
        DataTable dt = new DataTable();
        



        private void btnSachDaMuon_Click(object sender, EventArgs e)
        {
            frmSachDaMuon sdm = new frmSachDaMuon();
            sdm.ShowDialog();
        }

        private void frmThongTinThanhVien_Load(object sender, EventArgs e)
        {
            DataRow dr;
            dt = dgcontrol.laymataikhoan();
            if (dt.Rows.Count == 0)
            {
                lblDiaChi.Visible = false;
                lblGioiTinh.Visible = false;
                lblLoaiThe.Visible = false;
                lblMaThanhVien.Visible = false;
                lblNamSinh.Visible = false;
                lblNgayHetHan.Visible = false;
                lblNgayLamThe.Visible = false;
                lblNgheNghiep.Visible = false;
                lblNoiLamViec.Visible = false;
                lblSoCMND.Visible = false;
                lblSoDienThoai.Visible = false;
                lblSoTienNo.Visible = false;
                lblTenThanhVien.Visible = false;
                lblTrangThai.Visible = false;
                lblPass.Visible = false;
                linklblPass.Visible = false;
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dr = dt.Rows[i];
                if(FrmDangNhap.txt1 == dr["MATAIKHOAN"].ToString())
                {
                    lblDiaChi.Text = dr["DIACHI"].ToString();
                    lblGioiTinh.Text = dr["GIOITINH"].ToString();
                    lblLoaiThe.Text = dr["MALOAITHE"].ToString();
                    lblMaThanhVien.Text = dr["MADG"].ToString();
                    lblNamSinh.Text = dr["NGSINH"].ToString();
                    lblNgayHetHan.Text = dr["NGHETHAN"].ToString();
                    lblNgayLamThe.Text = dr["NGLAMTHE"].ToString();
                    lblNgheNghiep.Text = dr["NGHENGHIEP"].ToString();
                    lblNoiLamViec.Text = dr["NOILAMVIEC"].ToString();
                    lblSoCMND.Text = dr["CMND"].ToString();
                    lblSoDienThoai.Text = dr["DIENTHOAI"].ToString();
                    lblSoTienNo.Text = dr["SOTIENNO"].ToString();
                    lblTenThanhVien.Text = dr["HOTEN"].ToString();
                    lblTrangThai.Text = dr["TRANGTHAI"].ToString();
                    lblPass.Text = dr["MATKHAU"].ToString();
                }
                else
                {
                    lblDiaChi.Visible = false;
                    lblGioiTinh.Visible = false;
                    lblLoaiThe.Visible = false;
                    lblMaThanhVien.Visible = false;
                    lblNamSinh.Visible = false;
                    lblNgayHetHan.Visible = false;
                    lblNgayLamThe.Visible = false;
                    lblNgheNghiep.Visible = false;
                    lblNoiLamViec.Visible = false;
                    lblSoCMND.Visible = false;
                    lblSoDienThoai.Visible = false;
                    lblSoTienNo.Visible = false;
                    lblTenThanhVien.Visible = false;
                    lblTrangThai.Visible = false;
                    lblPass.Visible = false;
                }

                
            }
        }

        private void linklblPass_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            frmDoiMatKhau dmk = new frmDoiMatKhau();
            dmk.Show();
        }
    }
}
